package com.rpframework.website.device.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.rpframework.core.BaseService;
import com.rpframework.core.exception.AdminIllegalArgumentException;
import com.rpframework.utils.Pager;
import com.rpframework.website.device.dao.ICPropertyDao;
import com.rpframework.website.device.domain.CProperty;
@Service
public class CPropertyService extends BaseService{
	@Resource  ICPropertyDao icpdao;
	
	
	/**
	 * 循环物业
	 * @param id
	 * @return
	 */
	
	public Pager<CProperty> getpager(Pager<CProperty> pager) {
		long startTime=System.currentTimeMillis();
		List<CProperty> list = icpdao.dopager(this.packageMyBatisParam(pager));
		pager.setItemList(list);
		pager.setCostTime(System.currentTimeMillis() - startTime);
		pager.setTotalCount(list.size());
		return pager;
	}
	/**
	 * 根据id删除 信息
	 * @param id
	 * @return
	 */
	public boolean deletecProperty(String id) {
		if(StringUtils.isBlank(id)){
			throw new AdminIllegalArgumentException("不存在的ID:" + id);
		}
		return icpdao.delete(id);
	}
	/**
	 * 根据id查询 信息
	 * @param id
	 * @return
	 */
	public CProperty selectcProperty(String id) {
		if(StringUtils.isBlank(id)){
			throw new AdminIllegalArgumentException("不存在的ID:" + id);
		}
		Integer cc=Integer.parseInt(id);
		return icpdao.select(cc);
	}
	/**
	 * 添加
	 * @param id
	 * @return
	 */
	public boolean insertcProperty(CProperty school) {
		// TODO Auto-generated method stub
		return icpdao.insert(school);
	}

	public boolean updatecProperty(CProperty school) {
		// TODO Auto-generated method stub
		
		return icpdao.update(school);
	}
//通过名字查询
	public CProperty findUserByPhone(String name) {
		// TODO Auto-generated method stub
		return icpdao.findUserByPhone(name);
	}
	public List<CProperty> selectall() {
		// TODO Auto-generated method stub
		return icpdao.selectcpall();
	}
	public List<CProperty> listcity(String cityid) {
		
		return icpdao.listcitylist(cityid);
	}
}
